{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "## list 遍历"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "69517a6354de4172"
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "USER_AGENT environment variable not set, consider setting it to identify your requests.\n"
     ]
    }
   ],
   "source": [
    "from langchain_community.document_loaders import WebBaseLoader\n",
    "\n",
    "urls = [\n",
    "    \"https://lilianweng.github.io/posts/2023-06-23-agent/\",\n",
    "    \"https://lilianweng.github.io/posts/2023-03-15-prompt-engineering/\",\n",
    "    \"https://lilianweng.github.io/posts/2023-10-25-adv-attack-llm/\",\n",
    "]\n",
    "\n",
    "# 使用 WebBaseLoader 从每个 URL 加载内容\n",
    "docs = [WebBaseLoader(url).load() for url in urls]\n",
    "# 将所有文档列表展平为单个列表\n",
    "docs_list = [item for sublist in docs for item in sublist]"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-11-01T07:32:38.856420Z",
     "start_time": "2024-11-01T07:30:50.131662Z"
    }
   },
   "id": "16ee26e8330e3f9f",
   "execution_count": 1
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
